const integralModel = require('../models/integralModel')
const create = async data => {
  integralModel.create(Object.assign({createDate: new Date()}, data));
}

const find = async (ctx, next) => {
  const curUserId = ctx.state.user.userId;
  const result = await integralModel.find({
	userId: curUserId  
  }, null , {
    sort: {
      createDate: 'asc'
    }
  });
  if (result) {
    ctx.body = {
      code: 1,
      data: result
    };
  }
}

module.exports = {
  create,
  find
};